/*analyses for Oneal and Tir's "Does the Diversionary Use of Force Threaten the
Democratic Peace," International Studies Quarterly, Table 2: 4-7-2006*/

set mem 120m

use c:\growth\isqfinal\otdirect

desc 
summ

/*make minimum value of caprat positive and generate square*/
replace lncaprat=lncaprat+10.3
gen lncapsq=lncaprat^2

/*make sure growth not measured across leaders*/
#del ;
sort state target year;
quietly by state target: gen grow_stldr=grow_st if (leadid_st==leadid_st[_n-1] &
      leadid_st==leadid_st[_n-2]);
quietly by state target: gen grow_tgtldr=grow_tgt if (leadid_tgt==leadid_tgt[_n-1] &
      leadid_tgt==leadid_tgt[_n-2]);
#del cr

/*aut-aut is omitted category*/
gen aut_dem=1 if autoc_st_cg==1 & democ_tgt_cg==1
replace aut_dem=0 if aut_dem==.             

gen dem_aut=1 if democ_st_cg==1 & autoc_tgt_cg==1
replace dem_aut=0 if dem_aut==.             

gen dem_dem=1 if democ_st_cg==1 & democ_tgt_cg==1
replace dem_dem=0 if dem_dem==.            

gen aut_mix=1 if autoc_st_cg==1 & mixed_tgt_cg==1
replace aut_mix=0 if aut_mix==.

gen dem_mix=1 if democ_st_cg==1 & mixed_tgt_cg==1
replace dem_mix=0 if dem_mix==.

gen mix_dem=1 if mixed_st_cg==1 & democ_tgt_cg==1
replace mix_dem=0 if mix_dem==.

gen mix_aut=1 if mixed_st_cg==1 & autoc_tgt_cg==1
replace mix_aut=0 if mix_aut==.

gen mix_mix=1 if mixed_st_cg==1 & mixed_tgt_cg==1
replace mix_mix=0 if mix_mix==.

gen logdist=ln(distance)

drop if depend>1

drop if grow_stldr==.
/*drop exactly zero growth b/c result of interpol of rgdppc*/
drop if grow_stldr==0

/*create control for number of states in system for non-rel dyads*/
gen systsize=-ln(numstate) if ~(dircont==1 | majpower==1)
replace systsize=0 if systsize==.

gen dyadid=(1000*state)+target

/*all dyads, fatal disputes in year t+1, originator + side A*/
#del ;
/*TABLE 2, COLUMN 1*/
logit finitsda dem_* aut_* mix_* depend lncaprat lncapsq allies dircont logdist
      majpower systsize pyfatA _spl*, nolog cluster(dyadid);  
testparm lncap*;

/*TABLE 2, COLUMN 2: include only signif dyadic pairs*/
logit finitsda dem_* aut_dem depend lncaprat lncapsq allies dircont logdist
      majpower systsize pyfatA _spl*, nolog cluster(dyadid);  
testparm lncap*;

gen grw_st_da=dem_aut*grow_stldr;
gen grw_st_dd=dem_dem*grow_stldr;
gen grw_st_dm=dem_mix*grow_stldr;

/*TABLE 2, COLUMN 3*/
logit finitsda dem_* aut_dem grw* depend lncaprat lncapsq allies dircont logdist
      majpower systsize pyfatA _spl*, nolog cluster(dyadid);  
testparm lncap*;
testparm grw_st_*;
test grw_st_dd=grw_st_dm;
test grw_st_dd=grw_st_da, accumulate;

exit;


